/* * * * * * * * * * * * * * * * * * * * * *
*   Copyright (c) ycq_work@163.com
*   File:     testVector.cpp
*   Author:   ycq
*   e-mail：  ycq_work@163.com
*   Time:     2023-07-15
*   Description:
* * * * * * * * * * * * * * * * * * * * * * */

#include <iostream>
#include <cstdarg>

#include "../stl/MxgVector.h"

using namespace mxg::stl;

namespace testVector{

static void fun(){
    vector<int> vec(2);
    if(vec.empty())
    {
        std::cout << "vector is empty !" << std::endl;
    }
    for(int i = 0; i < vec.size (); ++i)
    {
        std::cout << "vec[" << i << "] = " <<vec[i] << " ";
    }
    std::cout << '\n';
    std::cout << "vec.capactity = " <<vec.capacity () << std::endl;
    vec.reserve ();
    std::cout << "vec.capactity = " <<vec.capacity () << std::endl;
    vec.push_back (2);
    for(int i = 0; i < vec.size (); ++i)
    {
        std::cout << "vec[" << i << "] = " <<vec[i] << " ";
    }
    std::cout << '\n';

    vec.reserve ();
    std::cout << "vec.capactity = " <<vec.capacity () << std::endl;
    vec.push_back (3);
    for(int i = 0; i < vec.size (); ++i)
    {
        std::cout << "vec[" << i << "] = " <<vec[i] << " ";
    }
    std::cout << '\n';

    vec.reserve ();
    std::cout << "vec.capactity = " << vec.capacity () << std::endl;

    for(int i = 0; i < vec.size (); ++i)
    {
        std::cout << "vec[" << i << "] = " << vec[i] << " ";
    }
    std::cout << '\n';

    vec.pop_back ();
    for(int i = 0; i < vec.size (); ++i)
    {
        std::cout << "vec[" << i << "] = " <<vec[i] << " ";
    }
    std::cout << '\n';

    std:: cout << "vec.back = " << vec.back () << std::endl;

    std::cout << "vec.front = " << vec.front () << std::endl;

    // std::cout << vec[1] << std::endl;

    std::cout << "vec.at(0) = " << vec.at(0);

    vec.clear();

    for(int i = 0; i < vec.size (); ++i)
    {
        std::cout << "vec[" << i << "] = " <<vec[i] << " ";
    }
    std::cout << '\n';

    std::cout << "after vec.clear() vec.size = " << vec.size () << std::endl;

    vector<int> vect(1000);

    std::cout << "vect.capacity = " << vect.capacity () << std::endl;

    vect.shrink_to_fit ();

    std::cout << "vect.capacity = " << vect.capacity () << std::endl;

    int data = 23;

    vect.push_back (data);

    std::cout << "vect.capacity = " << vect.capacity () << std::endl;

    vect.push_back (25);
    vect.push_back (56);

    std::cout << "vect.capacity = " << vect.capacity () << std::endl;

    for(int i = 0; i < vect.size (); ++i)
    {
        std::cout << "vect[" << i << "] = " << vect[i] << " ";
    }
    std::cout << '\n';

    vect.shrink_to_fit ();

    std::cout << "vect.capacity = " << vect.capacity () << std::endl;

    vec.insert (0, 345);

    for(int i = 0; i < vec.size (); ++i)
    {
        std::cout << "vec[" << i << "] = " << vec[i] << " ";
    }
    std::cout << '\n';

    vec.insert (0, data);

    for(int i = 0; i < vec.size (); ++i)
    {
        std::cout << "vec[" << i << "] = " << vec[i] << " ";
    }
    std::cout << '\n';

    vect.insert (1, vec);

    for(int i = 0; i < vect.size (); ++i)
    {
        std::cout << "vect[" << i << "] = " << vect[i] << " ";
    }
    std::cout << '\n';

    vect.emplace (1, 999);

    for(int i = 0; i < vect.size (); ++i)
    {
        std::cout << "vect[" << i << "] = " << vect[i] << " ";
    }
    std::cout << '\n';

}

template <typename T>
static void fun(int count, T&& data, ...){

}

} // namespace testVector
